const http = uni.$u.http
import store from '../store/index.js'
export default {
    login: (data) => http.post('/member/login', data),
    companylogin: (data) => http.post('/customer/login', data),
    register: (data) => http.post('/member/register', data),
    // 用户详情
    memberDetail: (id) => http.get(`/member/${id}`),
    memberUpdate: (data) => http.put(`/member/${data.id}`, data),
    // 首页轮播
    bannerList: (type = 1) => http.get('/banner/list', { status: 1, type }),
    // 分类列表
    categoryList: () => http.get('/category/list2', { status: 1 }),
    // 商品
    goodsList: () => http.get('/goods/list', { status: 1 }),
    goodsDetail: (id) => http.get(`/goods/${id}`),
    // 地址
    addressList: (data) => http.get('/address/list', { ...data }),
    addressDelete: (id) => http.delete(`/address/${id}`),
    addressDetail: (id) => http.get(`/address/${id}`),
    addAddress: (data) => http.post('/address', data),
    addressUpdate: (data) => http.put(`/address/${data.id}`, data),
    // 开票
    invoiceCreate: (data) => http.post('/invoice', data),
    // 意见反馈
    feedbackCreate: (data) => http.post('/feedback', data),
    // 创建订单
    orderCreate: (data) => http.post('/order',  {
        ...data,
        company_id: store.state.userInfo ? store.state.userInfo.company_id : 0
    }),
    updateOrder: (data) => http.put(`/order/${data.id}`, data),
    orderList: (data) => http.get('/order/list', data),
    // 创建充值
    rechargeCreate: (data) => http.post('/recharge', data),
    // 充值记录
    rechargeList: (data) => http.get('/recharge/list', data),
}
